<?php

class Main_UserController extends Zend_Controller_Action {
	
	public function init() {
		/* Initialize action controller here */
	}
	
	public function indexAction() {
		// action body
	}
	
	public function registrationAction() {
		$form = new Main_Form_Registration ();
		$this->view->form = $form;
		if ($this->getRequest ()->isPost ()) {
			$formData = $this->getRequest ()->getPost ();
			if ($form->isValid ( $formData )) {
				$userModel = new Main_Model_DbTable_Users ();
				$newUser = array ('firstName' => $formData ['firstName'], 'lastName' => $formData ['lastName'], 'fullName' => $formData ['firstName'] . ' ' . $formData ['lastName'], 'email' => $formData ['email'], 'password' => md5 ( $formData ['password'] ), 'role' => 'user' );
				$userModel->insert ( $newUser );
				$this->_helper->redirector ( 'index', 'index' );
			}
		}
	}

}

